package com.yin.interceptor;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;

/**
*@author LSY
*Time: 2018年12月26日下午3:22:07
*
*
*/
public class SessionInterceptor implements HandlerInterceptor{

	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws IOException {
		if(request.getRequestURI().equals("/user/login") || request.getRequestURI().equals("/user/login_view")) {
			return true;
		}
		Object obj = request.getSession().getAttribute("user");
		if(obj == null) {
			response.sendRedirect("/user/login_view");
			return false;
		}
		
		
		return true;
	}
}
